
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.opencv.core.Mat;
import org.opencv.core.MatOfDMatch;
import org.opencv.core.MatOfKeyPoint;
import org.opencv.core.Size;
import org.opencv.features2d.DMatch;
import org.opencv.features2d.DescriptorExtractor;
import org.opencv.features2d.DescriptorMatcher;
import org.opencv.features2d.FeatureDetector;
import org.opencv.features2d.Features2d;
import org.opencv.highgui.Highgui;
import org.opencv.imgproc.Imgproc;

public class Match {

	Match() {

		System.loadLibrary("opencv_java244");

		Mat frame = new Mat();
		Mat frame2 = new Mat();

		Mat frame3 = new Mat();
		Mat frame4 = new Mat();
		Mat frame5 = new Mat();
		Mat frame6 = new Mat();
		Mat frame7 = new Mat(new Size(500, 300), Imgproc.COLOR_RGB2GRAY);
        int i=1;
		for (;i<=42;i++){
		frame = Highgui.imread(i+".jpg");

		// Highgui.imwrite("resize.jpg",frame2);
		Imgproc.resize(frame, frame2, new Size(500, 300));

		Imgproc.cvtColor(frame2, frame2, Imgproc.COLOR_RGB2GRAY);

		FeatureDetector fd = FeatureDetector
				.create(FeatureDetector.BRISK);

		MatOfKeyPoint kps = new MatOfKeyPoint();
		fd.detect(frame2, kps);	
		System.out.println("key points of image"+i+" = " + kps.size());
		

		DescriptorExtractor de = DescriptorExtractor
				.create(DescriptorExtractor.SURF);
		Mat descript = new Mat();

		de.compute(frame2, kps, descript);
		System.out.println("descriptor length of image "+i+" = "
				+ descript.size());
		
		Features2d.drawKeypoints(frame2, kps, frame5);

		Highgui.imwrite("pic"+i+".jpg", frame5);
	}

	}

	public static void main(String[] argv) {

		new Match();
	}
}
